package com.chendx.article.controller.v2;

import com.chendx.api.article.ArticleHomeControllerApi;
import com.chendx.article.service.ApArticleService;
import com.chendx.common.constants.article.ArticleConstants;
import com.chendx.model.article.dtos.ArticleHomeDto;
import com.chendx.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by chendx on 2022/3/7.
 */
@RestController
@RequestMapping("/api/v2/article")
public class ArticleIndexController implements ArticleHomeControllerApi {

    @Autowired
    private ApArticleService articleService;

    @PostMapping("/load")
    @Override
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return articleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    @PostMapping("/loadmore")
    @Override
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return articleService.load(dto, ArticleConstants.LOADTYPE_LOAD_MORE);
    }

    @PostMapping("/loadnew")
    @Override
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return articleService.load(dto,ArticleConstants.LOADTYPE_LOAD_NEW);
    }
}
